#include <bits/stdc++.h>
using namespace std;
#include <atcoder/segtree>
using namespace atcoder;
using ll = long long;
using pii = pair<int, int>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 2e5 + 5;

using S = int;
int op(S l, S r) { return max(l, r); }
int e() { return 0; }

int solve(int l, int r, segtree<S, op, e>& seg) {
  int n1 = 1, n2 = (r + 1 - l) / 2;
  while (n1 <= n2) {
    int mid = (n1 + n2) >> 1;
    int d = max(mid, seg.prod(l - 1, l - 1 + mid));
    int x = l + mid - 1;
    int y = x + d;
    if (y <= r)
      n1 = mid + 1;
    else
      n2 = mid - 1;
  }
  return n2;
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int n, m;
  cin >> n;
  vector<int> a(n);
  rep(i, 0, n - 1) cin >> a[i];
  vector<int> d(n);
  rep(i, 0, n - 1) {
    d[i] = lower_bound(a.begin(), a.end(), a[i] * 2) - a.begin() - i;
  }
  segtree<S, op, e> seg(d);
  cin >> m;
  while (m--) {
    int l, r;
    cin >> l >> r;
    cout << solve(l, r, seg) << endl;
  }
  return 0;
}